<!--授予角色权限-->
<template>
  <div class="wrapper-container">
     <div class="search-container">
      <div class="search-container-left">
        <div class="search-container-item" style="display:flex; ">
          <span>学期：</span>
          <el-select
            v-model="trem"
            style="width: 90px"
            size="mini"
            placeholder="请选择"
          >
            <el-option
              v-for="item in xqList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <div style="margin-left:30px;margin-top:3px">
          
          </div>
        </div>

      </div>
    </div>
    <div class="table-container">
      <el-table
        max-height="600"
        :data="tableData"   
        border
        @selection-change="handleSelectionChange"
        style="width: 100%"
        class="table-data"
        row-class-name="row-class"
        cell-class-name="cell-class"
        header-row-class-name="header-row-class"
        header-cell-class-name="header-cell-class"
      > 
        <el-table-column width="70" align="center" type="selection">
        </el-table-column>
        <el-table-column prop="permission" label="授权数据类型" align="center">
        </el-table-column>

        <el-table-column prop="system" label="教研室" align="center">
          <template slot-scope="scope">
            <SelectItem
          
              :name="''"
              :value="scope.row.system"
              @change="
                (e) => {
                  scope.row.system = e;
                }
              "
              :xqList="systemList"
            ></SelectItem>
            <!-- <span v-else>{{ scope.row.system }}</span> -->
          </template>
        </el-table-column>
        <el-table-column prop="role" label="被授予角色" align="center">
          <template slot-scope="scope">
            <SelectItem
             
              :name="''"
              :value="scope.row.role"
              @change="
                (e) => {
                  scope.row.role = e;
                }
              "
              :xqList="roleList"
            ></SelectItem>
            <!-- <span v-else>{{ scope.row.role }}</span> -->
          </template>
        </el-table-column>

        <el-table-column prop="people" label="被授予人" align="center">
          <template slot-scope="scope">
            <SelectItem
              :name="''"
              :value="scope.row.people"
              @change="
                (e) => {
                 scope.row.people = e;
                }
              "
              :xqList="peopleList"
            ></SelectItem>
          </template>
        </el-table-column>

      </el-table>
    </div>

    <div

      class="search-container"
      style="display: flex; justify-content: center !important"
    >
      <ButtonItem
        :name="'授权'"
        :link="''"
        :icon="''"
        @click="saverGroup"
     
        :buttonColor="'yellow'"
      ></ButtonItem>
        
    </div>
  </div> 

</template>

<script>
import {porGroup,saverGroup,getlist} from "@/api/teacher/admin";
import SelectItem from "../../../components/SelectItem.vue";
import InputItem from "../../../components/InputItem.vue";
import ButtonItem from "../../../components/ButtonItem.vue";
export default {
  components: {
    SelectItem,
    InputItem,
    ButtonItem,
  },
  data() {
    return {
    
      xq: "2022春",
      xqList: [
        {
          value: "2020春",
          label: "2020春",
        },
        {
          value: "2020夏",
          label: "2020夏",
        },
      ],
      systemList: [
        {
          value: "1493847871055126530",
          label: "教研室1",
        },
        {
          value: "1493847948423258113",
          label: "教研室2",
        },
        
      ],
      roleList: [
        {
          value: "教研室主任",
          label: "教研室主任",
        },
        {
          value: "队长",
          label: "队长",
        },
        {
          value: "大队长",
          label: "大队长",
        },
        {
          value: "系领导",
          label: "系领导",
        },
        {
          value: "教科处领导",
          label: "教科处领导",
        },
        {
          value: "管理员",
          label: "管理员",
        },
        {
          value: "无",
          label: "无",
        },
      ],
      teacherName: "",
      peopleList: [
        {
          value: "测试10",
          label: "测试10",
        }
      ],
       multipleSelection: [],
       multipleSelectionas: [],
       multipleSelectiones: [],
       multipleSelectionrs: [],
      peopleText: "被授予人",
      tableData: [
        {
          permission: "督导结果查看",
          system: "",
          role: "队长",
          people: "",
           sfzh:"140729199807250040",
        },
        {
          permission: "按教员统计",
          system: "",
          role: "队长",
          people: "",
           sfzh:"140729199807250040",
        },
        {
          permission: "按督导专家分析",
          system: "",
          role: "队长",
          people: "",
           sfzh:"140729199807250040",
        }
      ],
    };
  },
 
  methods: {
    handleSelectionChange(val) {
      console.log(val,"ssacac")
      for(let i=0; i<val.length;i++){
        val[i].ryzhpj =val[i].people + ":"+val[i].sfzh
      }
      console.log(val)
       val.forEach(item=>{
          if(this.multipleSelection.indexOf(item.ryzhpj) == -1){
            this.multipleSelection.push(item.ryzhpj)
          }
          if(this.multipleSelectionas.indexOf(item.permission)){
            this.multipleSelectionas.push(item.permission)
          }
          if(this.multipleSelectiones.indexOf(item.system) ){
            this.multipleSelectiones.push(item.system)
          }
          if(this.multipleSelectionrs.indexOf(item.role) == -1){
            this.multipleSelectionrs.push(item.role)
          }
        })
         console.log(this.multipleSelection)
    //   saverGroup(){
    //   let obj = {
    //        xq : this.xq,
    //        sqsjlx:"",
    //        sqsjfw:"李教员,张教员",
    //        bsyjs:"",

    //   }
    //    return new Promise(resolve => {
    //      saverGroup(obj).then((res) => { 
           
           
    //         console.log(  this.dataList ,"aaaaaaaaaaaaaaaaaaaaa")
    //     })
    //   })
    // },
    },
    
    saverGroup(){
      let obj = {
           xq : this.xq,
           sqsjlx:this.multipleSelectionas.join(","),
           ryzhpj:this.multipleSelection.toString(),
           bsyjs:this.multipleSelectionrs.join(","),
           jys:this.multipleSelectiones.join(","),
          sqsjfw:this.multipleSelectiones.join(","),
          //  :
          //  sqsjfwz:

      }
       return new Promise(resolve => {
         saverGroup(obj).then((res) => { 
           
           
            console.log( res.data.data ,"aaaaaaaaaaaaaaaaaaaaa")
        })
      })
    },

    givPer() {
   
    },
    backPer(){
  
    }
  },
  mounted() {
   
  },
};
</script>
<style lang="less" scoped>
.search-container {
  justify-content: flex-start !important;
}

.search-button {
  cursor: pointer;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 70px;
  height: 27px;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  border-radius: 6px;

  > span {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }

  > img {
    width: 19px;
    height: 19px;
    margin-right: 4px;
  }
}

.table-container {
  margin-top: 30px;

  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }

  .wrapper-button {
    display: flex;
    flex-direction: column;
    align-items: center;

    > div {
      margin-bottom: 8px;
    }
  }
}
</style>

<style lang="less" scoped>
@import "../../../styles/special.less";
.table-container::v-deep .el-table__header th {
  border-color: #c7d7eb !important;
  padding-left: 10px;
}
.filter-button::v-deep .el-radio-button .el-radio-button__inner {
  border-radius: 6px !important;
  border: 1px solid #02c86c;
  color: #02c86c;
  background-color: #dfffef;
}
.filter-button::v-deep
.el-radio-button__orig-radio:checked
+ .el-radio-button__inner {
  border: 1px solid #02c86c;
  color: white;
  background-color: #02c86c;
}
.wrapper-container {
  width: 1711px;
  margin: 0 auto;
}
.table-container {
  margin-top: 30px;

  .table-data {
    width: 100%;
    border: 0.8px solid #004ca7;
    border-radius: 9px;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}

.save-button {
  width: 87px;
  height: 36px;
  line-height: 36px;
  background: #fff6ef;
  border: 1px solid #f3b815;
  border-radius: 6px;
  font-size: 18px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #f3b815;
  text-align: center;
  margin: 82px auto;
}

.zuoyou {
  width: 200px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
</style>
